package com.info.zhiduoduo.repository.mapper.quota;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.info.zhiduoduo.repository.dto.quota.CityConfigDto;
import com.info.zhiduoduo.repository.entity.quota.CityConfig;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author bob
 * @since 2020-06-26
 */
public interface CityConfigMapper extends BaseMapper<CityConfig> {

	@Select(" select cc.*,ap.name as provinceName, ac.name as cityName, " +
			" atr.* from zdd_city_config cc " +
			" join zdd_address ap on ap.id = cc.province_id " +
			" join zdd_address ac on ac.id = cc.city_id " +
			" left join zdd_address_tax_rate atr on atr.addr_id = cc.id " +
			" where CONCAT(ap.name,ac.name) like '%${name}%' " +
			" and cc.deleted = 0 " +
			" order by cc.id asc ")
	List<CityConfigDto> findList(@Param("name") String name);

	@Select(" select * from zdd_city_config cc " +
			" where cc.city_id = #{cityId} ")
	CityConfig findByCityId(Integer cityId);
}
